﻿package org.libspark.betweenas3.core.tweens.decorators
{
	import org.libspark.betweenas3.core.tweens.AbstractTween;
	import org.libspark.betweenas3.core.tweens.IITween;
	import org.libspark.betweenas3.core.tweens.TweenDecorator;
	import org.libspark.betweenas3.tweens.ITween;
	
	/**
	 * ITween を逆に実行.
	 * 
	 * @author	yossy:beinteractive
	 */
	public class ReversedTween extends TweenDecorator
	{
		public function ReversedTween(baseTween:IITween, position:Number)
		{
			super(baseTween, position);
			
			_duration = baseTween.duration;
		}
		
		/**
		 * @inheritDoc
		 */
		override protected function internalUpdate(time:Number):void 
		{
			_baseTween.update(_duration - time);
		}
		
		/**
		 * @inheritDoc
		 */
		override protected function newInstance():AbstractTween 
		{
			return new ReversedTween(_baseTween.clone() as IITween, 0);
		}
	}
}